<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/jsp/business/include/doctype.jsp" %>
<%
String res = request.getParameter("res");
String cookieValue = "";
if ( res == null) {
	Cookie[] cookie = request.getCookies();
	for (int i=0; i<cookie.length; i++) {
		if ("resCookieVal".equals(cookie[i].getName())) {
			request.setAttribute("res", cookie[i].getValue());
			cookieValue = cookie[i].getValue();
		}
	}
}
%>
<script type="text/javascript">
	function appBack() {
		document.location.href='#';
	}
	function setCookie( name, value, expiredays ) { 
		var todayDate = new Date(); 
		todayDate.setDate( todayDate.getDate() + expiredays ); 
		document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";" 
	} 
	function resCookie(frm) {
		var del;
		var sel = document.getElementById('res');
		if (sel.value != '<%=cookieValue%>') {
			del=confirm("기본식당으로 지정하시겠습니까?");
			if (del==true) {
				setCookie( "resCookieVal", sel.value , 365);
				alert("기본식당으로 지정되었습니다.");
			}
		}
		return false;
	}
	function selectChange(value) {
		location.href="${requestScope.contextPath}/business/mCafeteriaMenu/mCafeteriaMenu.do?YMD=${year}-${month}-${day}&res=" + value;
	}
	//의견쓰기
	function fnRestOpinionOk(){
		var fm2 = document.form2;
		if(fm2.inOpinion.value =="" ){
			alert("댓글을 작성해 주세요.");
			fm2.inOpinion.focus();
			return;
		}
		fm2.action = "${requestScope.contextPath}/business/mCafeteriaMenu/mCafeteriaMenuOpinion.do";
		fm2.submit();
	}
</script>

</head>
<body>
	<div id="wrap">
		<div class="header">
			<h1>구내식당</h1>
		</div><!-- // header -->
		<div class="content">
			<div class="know_frm">
				<form name="form" action="${requestScope.contextPath}/business/mCafeteriaMenu/mCafeteriaMenu.do" method="post" >
				<input type="hidden" name="year" value="${year}" />
				<input type="hidden" name="month" value="${month}" />
				<input type="hidden" name="day" value="${day}" />
					<fieldset>
						<legend>구내식당 메뉴 검색하기</legend>
						<select id="res" title="검색어 선택" style="width:225px;" name="res" onChange="selectChange(this.value);">
							<c:forEach items="${mapList}" var="mapInfo" varStatus="status">
								<c:choose>
			       					<c:when test="${res eq ''}">
			       						<option value="${mapInfo.CafeCD}" <c:if test="${resCookie eq mapInfo.CafeCD}"> selected="selected" </c:if> >${mapInfo.CafeName}</option>
			       					</c:when>
									<c:otherwise>
										<option value="${mapInfo.CafeCD}" <c:if test="${res eq mapInfo.CafeCD}"> selected="selected" </c:if> >${mapInfo.CafeName}</option>
									</c:otherwise>
								</c:choose>
							</c:forEach>
						</select>
						<img src="${requestScope.contextPath}/images/btn/btn_default.gif" alt="기본지정" onclick="resCookie();" />
					</fieldset>
				</form>
			</div><!-- // know_frm -->
			<div class="reservation">
				<p class="day">
					<a href="javascript:goUrl('${requestScope.contextPath}/business/mCafeteriaMenu/mCafeteriaMenu.do?YMD=${prevYear}-${prevMonth}-${prevDay}&res=${res}');">
						<img src="${requestScope.contextPath}/images/btn/btn_prev1.gif" alt="이전으로" />
					</a>
					<span>${year}년 ${month}월 ${day}일</span>
					<a href="javascript:goUrl('${requestScope.contextPath}/business/mCafeteriaMenu/mCafeteriaMenu.do?YMD=${nextYear}-${nextMonth}-${nextDay}&res=${res}');">
						<img src="${requestScope.contextPath}/images/btn/btn_next1.gif" alt="다음으로" />
					</a>
				</p>
				<div class="table4">
					<table summary="" cellspacing="0">
						<caption>구내 식당 메뉴</caption>
							<colgroup>
								<col style="width:33%;" />
								<col style="width:34%;" />
								<col style="width:33%;" />
							</colgroup>
							<thead>
								<tr>
									<th scope="col">아침</th>
									<th scope="col">점심</th>
									<th scope="col" class="last" >저녁</th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td rowspan="2">
									<c:choose>
									<c:when test="${map == null}">없음</c:when>
									<c:otherwise><c:out value="${map.Morning}" escapeXml="false" /></c:otherwise>
									</c:choose>
									</td>
									<td class="lunch1">
									<c:choose>
									<c:when test="${map == null}">없음</c:when>
									<c:otherwise><c:out value="${map.Lunch1}" escapeXml="false" /></c:otherwise>
									</c:choose>
									</td>
									<td rowspan="2" class="last">
									<c:choose>
									<c:when test="${map == null}">없음</c:when>
									<c:otherwise><c:out value="${map.Dinner}" escapeXml="false" /></c:otherwise>
									</c:choose>
									</td>
								</tr>
								
								
								<tr>
									<td class="lunch2">
									<c:choose>
									<c:when test="${map == null}">없음</c:when>
									<c:otherwise><c:out value="${map.Lunch2}" escapeXml="false" /></c:otherwise>
									</c:choose>
									</td>
								</tr>
							</tbody>
					</table>
				</div>
				<c:if test="${map != null}">
				<p class="btn_area2 btn_view"><a href="${requestScope.contextPath}/business/mCafeteriaMenu/mCafeteriaMenuScore.do?res=${res}&YMD=${year}-${month}-${day}"><img src="${requestScope.contextPath}/images/btn/btn_evaluate1.gif" alt="평가하기" /></a>&nbsp;&nbsp;<a href="${requestScope.contextPath}/business/mCafeteriaMenu/mCafeteriaBoard.do?YMD=${year}-${month}-${day}&res=${res}"><img src="${requestScope.contextPath}/images/btn/btn_opinion2.gif" alt="의견보기" /></a></p>
				</c:if>
			</div>
		</div><!-- // content -->
	</div><!-- // wrap -->
	<script>
		window.HybridApp.clearAllHistory(); 
	</script>
</body>
</html>
